<template>
  <div class="switch">
    <dui-switch v-model:value="value"></dui-switch>
    <div class="demo-actions">
      <!-- TODO：查看一个组件的源代码方法：在vite.config.js中配置vueCustomBlockTransforms属性（使用@vue/compiler-core中的baseParse） -->
      <button>查看代码</button>
    </div>
    <div class="demo-code">
      <pre>&lt;dui-switch v-model:value="value"&gt; &lt;/dui-switch&gt;</pre>
    </div>
  </div>
</template>

<script lang="ts">
import { ref } from 'vue'
import duiSwitch from '../dui/Switch.vue';

export default {
  components: { duiSwitch },
  setup () {
    const value = ref(false);

    return { value }
  }
}
</script>

<style lang="scss" scoped>
  $border-color: #d9d9d9;

  .demo {
    border: 1px solid $border-color;
    margin: 16px 0 32px;

    > h2 {
      font-size: 20px;
      padding: 8px 16px;
      border-bottom: 1px solid $border-color;
    }

    &-component {
      padding: 16px;
    }

    &-actions {
      padding: 8px 16px;
      border-top: 1px dashed $border-color;
    }

    &-code {
      padding: 8px 16px;
      border-top: 1px dashed $border-color;

      > pre {
        line-height: 1.1;
        font-family: Consolas, 'Courier New', Courier, monospace;
        margin: 0;
      }
    }
  }
</style>